using System;
using System.Collections.Generic;
using Me.Prettyprint.Cassandra.Utils;
using Me.Prettyprint.Hector.Api.Ddl;

namespace Me.Prettyprint.Hector.Api
{
    /// <summary>
    /// Serializes a type T from the given bytes, or vice a versa.
    /// 
    /// In cassandra column names and column values (and starting with 0.7.0 row
    /// keys) are all byte[]. To allow type safe conversion in java and keep all
    /// conversion code in one place we define the Extractor interface. Implementors
    /// * of the interface define type conversion according to their domains. A
    /// predefined set of common extractors can be found in the extractors package,
    /// for example StringSerializer.
    /// </summary>
    /// <typeparam name="T"></typeparam>
	public interface Serializer<T>
	{
        byte[] ToBytes(T obj);
        ByteBuffer ToByteBuffer(T obj);
        T FromBytes(byte[] bytes);
        T FromByteBuffer(ByteBuffer buff);
        ComparatorType GetComparatorType();
        Dictionary<byte[], V> ToBytesDictionary<V>(Dictionary<T, V> map);
        Dictionary<T, V> FromBytesDictionary<V>(Dictionary<byte[], V> map);
        List<byte[]> ToBytesList(List<T> list);
        List<T> FromBytesList(List<byte[]> list);
	}
}